
#pragma once

#include "zdbeval.h"
#include "zAcString.h"

#pragma pack (push, 8)

class UcDbDynBlockReference;
class UcDbDynBlockReferenceProperty;
class UcDbImpDynBlockReference;
class UcDbImpDynBlockReferenceProperty;
class UcDbImpDynBlockTableRecord;

class UcDbDynBlockReferenceProperty : public UcHeapOperators
{
public:
    enum UnitsType {
        kNoUnits = 0,
        kAngular,
        kDistance,
        kArea
    };
    UcDbDynBlockReferenceProperty ();
    virtual ~UcDbDynBlockReferenceProperty ();
    UcDbDynBlockReferenceProperty (const UcDbDynBlockReferenceProperty& other);
    UcDbDynBlockReferenceProperty& operator=(
            const UcDbDynBlockReferenceProperty& other);
    UcDbObjectId          blockId() const;
    UcString              propertyName ()   const;
    UcDb::DwgDataType	  propertyType ()  const;
    bool                  readOnly ()       const;
    bool                  show ()           const;
    UcString              description ()    const;
    UnitsType             unitsType () const;
    Ucad::ErrorStatus     getAllowedValues(UcDbEvalVariantArray& values);
    UcDbEvalVariant       value () const;
    Ucad::ErrorStatus     setValue (const UcDbEvalVariant& value);

	bool operator==(const UcDbDynBlockReferenceProperty& other);
private:

    UcDbImpDynBlockReferenceProperty* mpImp;
    friend class UcDbImpDynBlockReferenceProperty;
    friend class UcDbImpDynBlockReference;
};

typedef UcArray<UcDbDynBlockReferenceProperty,
        UcArrayObjectCopyReallocator<UcDbDynBlockReferenceProperty> >
             UcDbDynBlockReferencePropertyArray;

class UcDbDynBlockReference : public UcHeapOperators
{
public:
    UcDbDynBlockReference(UcDbObjectId blockRefId);
    UcDbDynBlockReference(UcDbBlockReference* pRef);
    virtual ~UcDbDynBlockReference ();
    static bool       isDynamicBlock (UcDbObjectId blockTableRecordId);
    bool              isDynamicBlock () const;
    UcDbObjectId blockId() const;
    void              getBlockProperties (
                        UcDbDynBlockReferencePropertyArray& properties) const;
    Ucad::ErrorStatus resetBlock ();
    Ucad::ErrorStatus convertToStaticBlock ();
    Ucad::ErrorStatus convertToStaticBlock (const UcString& newBlockName);
    UcDbObjectId      dynamicBlockTableRecord () const;
    UcDbObjectId      anonymousBlockTableRecord () const;

private:
    UcDbDynBlockReference();

    UcDbImpDynBlockReference* mpImp;
};

#pragma pack (pop)

